package com.hujia.hjsurprisemeal.util;

public class Result<T> {
    private boolean success;
    private T data;
    private String message;
    private int code;

    private Result(boolean success, T data, String message, int code) {
        this.success = success;
        this.data = data;
        this.message = message;
        this.code = code;
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(true, data, "success", 200);
    }

    public static Result error(String message) {
        return new Result<>(false, null, message, 500);
    }

    // Getters and setters
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}